package com.sixteengroup.personnelms.service.admin;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sixteengroup.personnelms.bean.User;
import com.sixteengroup.personnelms.bean.log.LoginLog;
import com.sixteengroup.personnelms.bean.log.StaffFlowLog;
import com.sixteengroup.personnelms.dao.admin.LogDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogService {
    @Autowired
    LogDao logDao;

    public PageInfo<StaffFlowLog> getFlowList(StaffFlowLog staffFlowLog) {
        //分页插件  只要传递当前页数和页数大小  自动计算，并查询总条数
        PageHelper.startPage(staffFlowLog.getCurrentPage(), staffFlowLog.getPagesize());
        List<StaffFlowLog> performanceList = logDao.getFlowList(staffFlowLog);
        PageInfo<StaffFlowLog> page = new PageInfo<>(performanceList);
        return page;
    }

    public void saveLoginLog(User user) {
        logDao.saveLoginLog(user);
    }

    public PageInfo<LoginLog> getLoginList(LoginLog loginLog) {
        PageHelper.startPage(loginLog.getCurrentPage(), loginLog.getPagesize());
        List<LoginLog> loginList = logDao.getLoginList(loginLog);
        PageInfo<LoginLog> page = new PageInfo<>(loginList);
        return page;
    }


    public void deleteLoginlog(Integer id) {
        logDao.deleteLoginlog(id);
    }

    public void deleteFlow(Integer id) {
        logDao.deleteFlow(id);
    }

    public List<String> partInform() {
        return logDao.partInform();
    }

    public List<Integer> numberInform() {
        return logDao.numberInform();
    }
}
